import zipfile
import os 

def unzip_downloaded_dicom(p):
    f = zipfile.ZipFile(p,'r') # 压缩文件位置
    all_files = []

    for file in f.namelist():
        f.extract(file,"../Dicom_download")
        all_files.append(os.path.join("../Dicom_download", file))

    f.close()

    return all_files


def get_all_modality_dir(all_unzip_files):
    all_modality_dir = []
    for p in all_unzip_files:
        dir_name = "/".join(p.split("/")[:-1])
        if dir_name in all_modality_dir:
            continue
        else :
            all_modality_dir.append(dir_name)
            
    return all_modality_dir 

